package GameLogic;

import java.awt.Color;
import java.awt.Point;
import java.awt.geom.Point2D;
import java.util.TreeMap;

public class Tower implements ITower
{
    public Tower(int x, int y)
    {
        this.x = x; this.y = y;
    }
    public Tower(TowerType t)
    {
        type = t;
        MinDamage = t.MinDamage;
        MaxDamage = t.MaxDamage;
        Range = t.Range;
        cooldown = t.Cooldown;
        missileSpeed = t.missileSpeed;
    }

    public static Game g;
    public TowerType type;
    public int x, y;
    public int MinDamage,
               MaxDamage;
    public int Range;
    public double missileSpeed;
    public double cooldown,
                  curCooldown = 0;
    public Mob target;
    public double targetDist;
    public TreeMap<TBuff, TBuff> Buffs = new TreeMap<TBuff, TBuff>();
    
    public TowerType getType()
    {
        return type;
    }
    
    public double CalcDamage()
    {
        return (double)MinDamage + Math.random() * (double)(MaxDamage - MinDamage);
    }
    
    //1-liners
    public TowerType getUpgrade()
    {
        return type.upgradesTo;
    }
    public Color getColor() {
        return type.color;
    }
    public IMob getTarget() {
        return target;
    }
    public Point getPosition() {
        return new Point(x, y);
    }
    public Point2D getCenter()
    {
        return new Point2D.Double(x + type.size/2, y + type.size/2);
    }
    public String getName() {
        return type.name;
    }
    public String getDescription() {
        return type.desc;
    }
    public int getPrice() {
        return type.price;
    }
    public int getMinDamage() {
        return MinDamage;
    }
    public int getMaxDamage() {
        return MaxDamage;
    }
    public int getRange() {
        return Range;
    }
    public int getSize() {
        return type.size;
    }
    public DamageType getDamageType() {
        return type.dmgType;
    }
}